package com.youhong.teethcare.plaque.dialogs;

import android.app.Dialog;
import android.content.Context;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.youhong.teethcare.R;

/**
 * Created by Administrator on 2018/9/12.
 */
public class ToothMobilityChooseDialog extends Dialog {

    Button btn_ok;

    public void setCallback(MobilityOnClickCallback callback) {
        this.callback = callback;
    }

    MobilityOnClickCallback callback;
    EditText et;
    ImageView iv_close;


    public ToothMobilityChooseDialog(@NonNull Context context) {
        super(context);
        setContentView(R.layout.dialog_toothmobilitychoose);
        getViews();

    }

    public ToothMobilityChooseDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
        setContentView(R.layout.dialog_toothmobilitychoose);
        getViews();
    }

    private void getViews() {
        et = findViewById(R.id.dialog_et);

        btn_ok = findViewById(R.id.plaqueChoose_btn_ok);
        btn_ok.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                if (callback != null && et.getText().length() != 0) {

                    callback.onCallback(Integer.parseInt(et.getText().toString()));
                }else{

                    callback.onCallback(0);
                }
                ToothMobilityChooseDialog.this.dismiss();

            }
        });

        iv_close = findViewById(R.id.dialog_iv_close);
        iv_close.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ToothMobilityChooseDialog.this.dismiss();
            }
        });
    }

    public interface MobilityOnClickCallback {

        void onCallback(int value);
    }

}
